package com.puppet.building182.service.impl;

import com.puppet.building182.handler.MyAssert;
import com.puppet.building182.mapper.OwnerMapper;
import com.puppet.building182.pojo.Owner;
import com.puppet.building182.pojo.VO.OwnerVo;
import com.puppet.building182.pojo.enums.BuildingCode;
import com.puppet.building182.service.HouseService;
import com.puppet.building182.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OwnerServiceImpl implements OwnerService {
    @Autowired
    OwnerMapper ownerMapper;

    @Override
    public List<Owner> getOwners(String searchQuery) {
        return ownerMapper.getOwners(searchQuery);
    }

    @Override
    public Integer addOwner(Owner owner) {
        Integer result = ownerMapper.addOwner(owner);
        MyAssert.error(result <= 0, BuildingCode.SAVE_FAIL.getMessage());
        return result;
    }

    @Override
    public Integer deleteOwnerById(Integer id) {
        return ownerMapper.deleteOwnerById(id);
    }

    @Override
    public Integer deleteOwner(List<Integer> id) {
        return ownerMapper.deleteOwner(id);
    }

    @Override
    public Integer updateOwner(Owner owner) {
        return ownerMapper.updateOwner(owner);

    }

    @Override
    public Owner getOwnerById(Integer id) {
        return ownerMapper.getOwnerById(id);

    }

    @Override
    public List<OwnerVo> getOwnerNameAndId() {
        return ownerMapper.getOwnerNameAndId();

    }

    @Override
    public Integer selectOwner(Integer id) {
        return ownerMapper.selectById(id);
    }
}
